<!-- eslint-disable @typescript-eslint/no-explicit-any -->
<script lang="ts" setup>
import { onMounted, ref } from 'vue';

const Users = ref<any[]>([]);

const fetchUsers = async () => {
  try {
    const response = await fetch('http://localhost:8080/user/profile', {
      credentials: 'include',
      headers: {
        Accept: 'application/json',
        'Content-Type': 'application/json',
      },
    });
    if (!response.ok) {
      throw new Error('Network response was not ok');
    }
    const data = await response.json();
    Users.value = [data]; // 始终封装为数组
  } catch (error) {
    console.error('Error fetching admins data:', error);
    Users.value = [];
  }
};

onMounted(() => {
  fetchUsers();
});
</script>

<template>
  <el-table :data="Users || []" style="width: 100%">
    <el-table-column prop="id" label="ID" width="100" />
    <el-table-column prop="name" label="Name" width="180" />
    <el-table-column prop="password" label="Password" width="300" />
    <el-table-column prop="email" label="Email" />
  </el-table>
</template>
